/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package converters;

import bundle.CompanyAdquiredProfileFolderStateBundle;
import entities.CompanyAdquiredProfileFolderState;
import facades.CompanyAdquiredProfileFolderStateFacade;
import javax.ejb.EJB;
import javax.faces.bean.ApplicationScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.inject.Named;

/**
 *
 * @author damfercer
 */

@Named
@ApplicationScoped
public class CompanyAdquiredProfileFolderStateConverter implements Converter{
    @EJB
    private CompanyAdquiredProfileFolderStateFacade companyAdquiredProfileFolderStateFacade;
    @Override
    public CompanyAdquiredProfileFolderState getAsObject(FacesContext context, UIComponent component, String value) {
        CompanyAdquiredProfileFolderState comAdProFolSta=null;
        try {
            Integer i=new Integer(value);
            comAdProFolSta=companyAdquiredProfileFolderStateFacade.find(i);
        } catch (NumberFormatException e) {
            //System.err.println(e.getLocalizedMessage());
        }
        return comAdProFolSta;
        
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        String res=null;
        CompanyAdquiredProfileFolderState comAdProFolSta=null;
        if(value.getClass().equals(CompanyAdquiredProfileFolderState.class)){
            comAdProFolSta=(CompanyAdquiredProfileFolderState)value;
        }
        if(comAdProFolSta!=null){
            res= comAdProFolSta.getIdCompanyAdquiredProfileFolderState().toString();
        }
        return res;
    }
    
}
